//
//  NetWork.m
//  MansApp
//
//  Created by lanou3g on 15/7/30.
//  Copyright (c) 2015年 ACH. All rights reserved.
//

#import "NetWork.h"

@implementation NetWork

static NetWork *netWork;
+ (NetWork *)shareNetWork
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        netWork = [[NetWork alloc]init];
    });
    return netWork;
}

- (BOOL)rechability
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.baidu.com"];
    switch ([r currentReachabilityStatus]) {
        case NotReachable:
            NSLog(@"没有网络");
            return NO;
            break;
        case ReachableViaWWAN:
            NSLog(@"使用3G网络");
            return YES;
            break;
        case ReachableViaWiFi:
            NSLog(@"使用wifi网络");
            return YES;
            break;
    }
}

- (BOOL)reachabilityManager
{
    //打开网络监听
    [_manager.reachabilityManager startMonitoring];
    //监听网络变化
    [_manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
                //当网络不可用(无网络请求)
            case AFNetworkReachabilityStatusNotReachable:
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                break;
                
            default:
                break;
        }
        
        
    }];
    return YES;
}
@end
